class Solution {
    public int waysToStep(int n) {
        if(n == 1) return 1;
        if(n == 2) return 2;
        if(n == 3) return 4;
        int MOD = (int)1e9 + 7;//1e9默认是double类型的
        int[] dp = new int[n + 1];
        dp[1] = 1; dp[2] = 2; dp[3] = 4;
        for(int i = 4; i <= n; i++) {
            //结果可能很大，你需要对结果模1000000007
            dp[i] = ((dp[i - 1] + dp[i - 2]) % MOD  + dp[i - 3]) % MOD;
        }
        return dp[n];
    }
}
